package com.qfjy.controller;

import com.qfjy.entity.po.MeetingPub;
import com.qfjy.service.MeetingPubService;
import com.qfjy.util.result.ResultCode;
import com.qfjy.util.result.ResultJson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

/**
 * @ClassName MeetingPubController
 * @Description TODO
 * @Author guoweixin
 * @Date 2023/4/28
 * @Version 1.0
 */
@Controller
@RequestMapping("meetingPub")
@Slf4j
public class MeetingPubController {


    @Autowired
    private MeetingPubService meetingPubService;

    @GetMapping("select")
    @ResponseBody
    public ResultJson selectMeetingPubByPcode(@RequestParam("pcode") String pcode){
        //根据会议编号 得到会议详情
       MeetingPub meetingPub= meetingPubService.selectMeetingPubByPcode(pcode);

       if(meetingPub==null){
           return new ResultJson(null, ResultCode.NOT_DATA);
       }


       //根据会议编号 调用视频微服务的信息
        String url="http://localhost:8085/videoInfo/select?pcode="+meetingPub.getPcode();
       String result= restTemplate.getForObject(url,String.class);
        meetingPub.setRemark(result);

       return new ResultJson(meetingPub,ResultCode.SUCCESS);

    }

    @Autowired
    private RestTemplate restTemplate;
}
